package com.longxi.tianjintianbao.ui.activity.repair;

import android.content.Intent;
import android.media.Image;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.repair.RepairDetailAtPresenter;
import com.longxi.tianjintianbao.ui.view.repair_publish.IRepairDetailAtView;

import butterknife.BindView;

public class RepairDetailActivity extends BaseActivity<IRepairDetailAtView, RepairDetailAtPresenter> implements IRepairDetailAtView {
    @BindView(R.id.tvName)
    TextView mTvName;
    @BindView(R.id.tvAddress)
    TextView mTvAddress;
    @BindView(R.id.tvRepairArea)
    TextView mTvRepairArea;
    @BindView(R.id.tvRight)
    TextView tvRight;
    @BindView(R.id.tvRight2)
    TextView tvRight2;
    @BindView(R.id.tvRepairContent)
    TextView mTvRepairContent;
    @BindView(R.id.tvTime)
    TextView mTvTime;
    @BindView(R.id.tvProgress)
    TextView mTvProgress;

    @BindView(R.id.ivImage1)
    ImageView mIvImage1;
    @BindView(R.id.ivImage2)
    ImageView mIvImage2;
    @BindView(R.id.ivImage3)
    ImageView mIvImage3;
    @BindView(R.id.ivImage4)
    ImageView mIvImage4;

    @BindView(R.id.tvArrangedate)
    TextView mTvArrangedate;

    //调整信息
    @BindView(R.id.btnUpdate)
    Button mBtnUpdate;
    //立即派工
    @BindView(R.id.btnAllot)
    Button mBtnAllot;

    //立即接单
    @BindView(R.id.btnOrder)
    Button mBtnOrder;

    //开始
    @BindView(R.id.btnStart)
    Button mBtnStart;

    //无法完成
    @BindView(R.id.llCannot)
    LinearLayout mLlCannot;
    //暂停
    @BindView(R.id.btnPause)
    Button mBtnPause;
    //完成
    @BindView(R.id.btnComplete)
    Button mBtnComplete;

    @BindView(R.id.llState0)
    LinearLayout mLlState0;
    @BindView(R.id.llState1)
    LinearLayout mLlState1;
    @BindView(R.id.llState2)
    LinearLayout mLlState2;
    @BindView(R.id.llState3)
    LinearLayout mLlState3;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_repair_detail;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.getData();
    }

    @Override
    public void initListener() {
        super.initListener();
        mBtnUpdate.setOnClickListener(v -> mPresenter.toUpdateRepairContentActivity());
        mBtnAllot.setOnClickListener(v -> mPresenter.repairAreaJudgment());

        mBtnOrder.setOnClickListener(v -> mPresenter.order());
        mBtnStart.setOnClickListener(v -> mPresenter.start());
        mBtnPause.setOnClickListener(v -> mPresenter.pauseAndStart());
        mBtnComplete.setOnClickListener(v -> mPresenter.complete());

        tvRight.setOnClickListener(v -> mPresenter.scan());
        tvRight2.setOnClickListener(v -> mPresenter.plan());
    }

    @Override
    protected RepairDetailAtPresenter createPresenter() {
        return new RepairDetailAtPresenter(this);
    }

    @Override
    public TextView getTvName() {
        return mTvName;
    }

    @Override
    public TextView getTvAddress() {
        return mTvAddress;
    }

    @Override
    public TextView getTvRepairArea() {
        return mTvRepairArea;
    }

    @Override
    public TextView getTvRepairContent() {
        return mTvRepairContent;
    }

    @Override
    public TextView getTvTime() {
        return mTvTime;
    }

    @Override
    public TextView getTvProgress() {
        return mTvProgress;
    }

    @Override
    public ImageView getIvImage1() {
        return mIvImage1;
    }

    @Override
    public ImageView getIvImage2() {
        return mIvImage2;
    }

    @Override
    public ImageView getIvImage3() {
        return mIvImage3;
    }

    @Override
    public ImageView getIvImage4() {
        return mIvImage4;
    }

    @Override
    public TextView getTvArrangedate() {
        return mTvArrangedate;
    }

    @Override
    public Button getBtnUpdate() {
        return mBtnUpdate;
    }

    @Override
    public Button getBtnAllot() {
        return mBtnAllot;
    }

    @Override
    public Button getBtnStart() {
        return mBtnStart;
    }

    @Override
    public LinearLayout getLlCannot() {
        return mLlCannot;
    }

    @Override
    public Button getBtnPause() {
        return mBtnPause;
    }

    @Override
    public Button getBtnComplete() {
        return mBtnComplete;
    }

    @Override
    public Button getBtnOrder() {
        return mBtnOrder;
    }

    @Override
    public LinearLayout getLlState0() {
        return mLlState0;
    }

    @Override
    public LinearLayout getLlState1() {
        return mLlState1;
    }

    @Override
    public LinearLayout getLlState2() {
        return mLlState2;
    }

    @Override
    public LinearLayout getLlState3() {
        return mLlState3;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            mPresenter.RemindPreviousrefresh();
            return false;
        }else {
            return super.onKeyDown(keyCode, event);
        }
    }
}


